#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->radioButton_black,&QPushButton::clicked,this,&Widget::do_FontColor);
    connect(ui->radioButton_red,&QPushButton::clicked,this,&Widget::do_FontColor);
    connect(ui->radioButton_blue,&QPushButton::clicked,this,&Widget::do_FontColor);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_checkBox_clicked(bool checked)
{
    QFont font =ui->plainTextEdit->font();
    font.setUnderline(checked);
    ui->plainTextEdit->setFont(font);
}


void Widget::on_pushButton_2_clicked()
{
    ui->plainTextEdit->clear();
}


void Widget::on_checkBox_2_clicked(bool checked)
{
    QFont font=ui->plainTextEdit->font();
    font.setItalic(checked);
    ui->plainTextEdit->setFont(font);
}


void Widget::on_checkBox_3_clicked(bool checked)
{
    QFont font=ui->plainTextEdit->font();
    font.setBold(checked);
    ui->plainTextEdit->setFont(font);
}

void Widget::do_FontColor()
{
    QPalette plet =ui->plainTextEdit->palette();
    if(ui->radioButton_black->isChecked()){
        plet.setColor(QPalette::Text,Qt::black);
    }
    if(ui->radioButton_blue->isChecked()){
        plet.setColor(QPalette::Text,Qt::blue);
    }
    if(ui->radioButton_red->isChecked()){
        plet.setColor(QPalette::Text,Qt::red);
    }
    ui->plainTextEdit->setPalette(plet);
}




